<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<jsp:directive.include file="/controleDeAcesso/autenticado.jsp" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> Anuncios</title>
</head>
<body>
<f:view>
<h2>Anuncios de  <h:outputText value="#{principal.usuario.nome}"></h:outputText>
</h2>
<p>
 	<h:outputText value="#{principal.msg}" style="color: #FF0000"></h:outputText> 
</p>
		 <h:form >
			<h:commandLink action="#{principal.iniciarNovoAnuncio }">
				<h:outputText value="(+) Castrar um novo Anuncio"></h:outputText>
			</h:commandLink>
		</h:form> 
		 <h:form >
			<h:commandLink action="sairAnuncio">
				<h:outputText value="Sair"></h:outputText>
			</h:commandLink>
	
		</h:form> 
	<h:panelGrid border="0" cellpadding="1" columns="3" style="background-color: #BBE0FF">
		<h:dataTable border="1" value="#{principal.usuario.anuncios}" var="anuncio">
			<h:column id="column1">
				<f:facet name="header">
					<h:outputText value="Título"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.tituloAnuncio}"></h:outputText>
			</h:column>
			<h:column id="column2">
				<f:facet name="header">
					<h:outputText value="Nome"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.nomeProduto}"></h:outputText>
			</h:column>
			<h:column id="column3">
				<f:facet name="header">
					<h:outputText value="Preço"></h:outputText>
				</f:facet>
				<h:outputText value="#{anuncio.preco}">
				<f:convertNumber pattern="#,##0.00" minFractionDigits="2"  />  
				</h:outputText>
			</h:column>
				<h:column id="column4">
				<f:facet name="header">
					<h:outputText value="Ação"></h:outputText>
				</f:facet>
				<h:form>
					<h:commandLink value="Remover"
						action="#{principal.removerAnuncio }">
						<f:param name="idAnuncio" value="#{anuncio.id }"></f:param>
					</h:commandLink>
				</h:form>
			</h:column>
		</h:dataTable>
		</h:panelGrid>
	</f:view>
</body>
</html>